import {
  getLocalStore,
  setLocalStore,
  removeLocalStore
} from '@/libs/util'
export default {
  state: {
    isLocked: getLocalStore('isLocked', 'sessionStorage'),
    lockScreenPwd: getLocalStore('lockScreenPwd', 'sessionStorage')
  },
  mutations: {
    lockScreen(state, action) {
      state.isLocked = true;
      setLocalStore('isLocked', action, 'sessionStorage')
    },
    unlockScreen(state, action) {
      state.isLocked = false;
      state.lockScreenPwd = '';
      removeLocalStore('isLocked', 'sessionStorage');
      removeLocalStore('lockScreenPwd', 'sessionStorage');
    },
    setLockScreenPwd(state, lockScreenPwd) {
      var md5 = require('js-md5');
      let lockScreenPwdMd5 = md5('QAPlatform' + lockScreenPwd);
      state.lockScreenPwd = lockScreenPwdMd5;
      setLocalStore('lockScreenPwd', lockScreenPwdMd5, 'sessionStorage')
    }
  },
  getters: {},
  actions: {}
}
